# 构建阶段
FROM golang:1.24-alpine AS builder

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

# 复制所有代码
COPY . .

# 编译启动器
RUN cd cmd/start && go build -o starter

# 运行阶段
FROM alpine:3.17

WORKDIR /app

# 复制启动器和源码
COPY --from=builder /app/cmd/start/starter ./cmd/start/
COPY --from=builder /app/services ./services
COPY --from=builder /app/config ./config
COPY --from=builder /app/.env ./

# 安装Go环境
RUN apk add --no-cache go

EXPOSE 8080 8081 8082 8084 8085 8086

CMD ["./cmd/start/starter"]
    